// prime.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "iostream"

int _tmain(int argc, _TCHAR* argv[]){
	int pcheck; // counter variable for user input
	int pstore=2; // stores the value of the divisor
	bool prime=false;
	std::cout<<"Until what number should the program check for prime numbers?"<<std::endl;
	std::cin>>pcheck; 
	std::cout<<"The prime numbers up until ";
	std::cout<<pcheck;
	std::cout<<" are:"<<std::endl;
	std::cout<<"\n";
	std::cout<<"2"<<std::endl;
	for (int pvalue=3;pvalue<=pcheck;pvalue++){//first loop cycles through each potential prime
		while (prime==false){ 
				if (pvalue%pstore==0 || pvalue-pstore<=1)
					prime=true;
				else
					pstore++;
		}
		if (pvalue-pstore<=1)
			std::cout<<pvalue<<std::endl;
		prime=false;
		pstore=2;
	}
	return 0;
}